    <?php

    class CompetitorEditPanel extends QPanel {
        // Local instance of the CompetitorMetaControl
        protected $mctCompetitor;

        // Controls for Competitor's Data Fields
        public $lblId;
        public $lstSchool;
        public $txtACompetitor;
        public $lstEuserObject;
        public $calDate;
        public $txtNotes;
        public $lstRecord;

        // Other ListBoxes (if applicable) via Unique ReverseReferences and ManyToMany References

        // Other Controls
        public $btnSave;


        // Callback
        protected $strClosePanelMethod;


        public function txtACompetitor_Change($strParameter) {
            $objMemberArray = Org::QueryArray(
                    QQ::AndCondition(
                    QQ::OrCondition(
                    QQ::Equal(QQN::Org()->TypeId, OrgType::Publisher ),
                    QQ::Equal(QQN::Org()->TypeId, OrgType::BookShop),
                    QQ::Equal(QQN::Org()->TypeId, OrgType::BookDistributor)
                    ),
                    QQ::Like(QQN::Org()->Name, $strParameter . '%')
                    ),
                    QQ::Clause(QQ::OrderBy(QQN::Org()->Name))

            );
            $result = array();
            foreach($objMemberArray as $objMember) {
                $result[] = $objMember->Name;
            }
            return $result;
        }

        public function __construct($objParentObject, $strClosePanelMethod, $intId = null, $strControlId = null) {
            // Call the Parent
            try {
                parent::__construct($objParentObject, $strControlId);
            } catch (QCallerException $objExc) {
                $objExc->IncrementOffset();
                throw $objExc;
            }

            // Setup Callback and Template
            $this->strTemplate = __DOCROOT__.__MARKETING__. '/tpl/line.tpl.php';
            $this->strClosePanelMethod = $strClosePanelMethod;

            // Construct the CompetitorMetaControl
            // MAKE SURE we specify "$this" as the MetaControl's (and thus all subsequent controls') parent
            $this->mctCompetitor = CompetitorMetaControl::Create($this, $intId);

            // Call MetaControl's methods to create qcontrols based on Competitor's data fields

            //$this->lstSchool = $this->mctCompetitor->lstSchool_Create();
            $this->txtACompetitor = $this->mctCompetitor->txtACompetitor_Create();
            //$this->lstEuserObject = $this->mctCompetitor->lstEuserObject_Create();
            $this->calDate = $this->mctCompetitor->calDate_Create();
            $this->txtNotes = $this->mctCompetitor->txtNotes_Create();

            $this->txtNotes->Height="15";
            //$this->lstRecord = $this->mctCompetitor->lstRecord_Create();

            // Create Buttons and Actions on this Form
            $this->btnSave = new QButton($this);
            $this->btnSave->Text = QApplication::Translate('Add');
            $this->btnSave->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnSave_Click'));

            //$this->txtNotes->AddAction(new QBlurEvent(), new  QAjaxControlAction($this, 'txtNotes_Blur'));
            //$this->txtNotes->AddAction(new QClickEvent(), new  QAjaxControlAction($this, 'txtNotes_Click'));

            $this->btnSave->CausesValidation = $this;

        }

        // Control AjaxAction Event Handlers
        public function btnSave_Click($strFormId, $strControlId, $strParameter) {
            // Delegate "Save" processing to the CompetitorMetaControl
            $this->mctCompetitor->SaveCompetitor();
            $this->CloseSelf(true);
        }

        public function txtNotes_Click($strFormId, $strControlId, $strParameter) {
            //sleep(1);
            $this->txtNotes->Height="100";
            //$this->txtNotes->Text = $this->txtNotes->Text . "focus.... ";
        }

        public function txtNotes_Blur($strFormId, $strControlId, $strParameter) {
            //sleep(1);
            $this->txtNotes->Height="15";
            //$this->txtNotes->Text = $this->txtNotes->Text . "Blur.... ";
        }



        public function btnDelete_Click($strFormId, $strControlId, $strParameter) {
            // Delegate "Delete" processing to the CompetitorMetaControl
            $this->mctCompetitor->DeleteCompetitor();
            $this->CloseSelf(true);
        }

        public function btnCancel_Click($strFormId, $strControlId, $strParameter) {
            $this->CloseSelf(false);
        }

        // Close Myself and Call ClosePanelMethod Callback
        protected function CloseSelf() {
            $this->objParentControl->CloseReOpenEditPanel();
            $this->objParentControl->Refresh();
        }


    }
    ?>